package com.design01_builder.pattern02_factory.simple_factory.controller;

import com.design01_builder.pattern02_factory.simple_factory.entry.AwardInfo;
import com.design01_builder.pattern02_factory.simple_factory.entry.ResponseResult;
import com.design01_builder.pattern02_factory.simple_factory.factory.FreeGoodsFactory;
import com.design01_builder.pattern02_factory.simple_factory.service.IFreeGoods;

/**
 * @ClassName DeliverController
 * @Description TODO
 * @Author zhangjunhao
 * @DATE 2023/9/2 1:17
 */
public class DeliverController {

    //发放奖品
    public ResponseResult awardToUser(AwardInfo awardInfo) {
        try {
            IFreeGoods freeGoods = FreeGoodsFactory.getInstance(awardInfo.getAwardTypes());
            ResponseResult responseResult = freeGoods.sendFreeGoods(awardInfo);
            return responseResult;
        } catch (Exception e) {
            e.printStackTrace();
            return new ResponseResult("201", "奖品发放失败!");
        }
    }

}
